﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SwiftMVVM.ViewModel
{
    /// <summary>
    /// The DependsOnAttribute marks a property that should get a NotifyPropertyChanged
    /// immediately after the property it depends on gets a NotifyPropertyChanged
    /// </summary>
    [AttributeUsage(AttributeTargets.Property, Inherited = true, AllowMultiple = true)]
    public sealed class DependsOnAttribute : Attribute
    {
        /// <summary>
        /// Instantiates a new DependsOnAttribute
        /// </summary>
        /// <param name="property">The property name we depend on. This property must exist
        /// on this object.</param>
        public DependsOnAttribute(string property)
            : this("", property) { }

        /// <summary>
        /// Instantiates a new DependsOnAttribute
        /// </summary>
        /// <param name="source">The source object path relative to this object</param>
        /// <param name="property">The property we depend on, in the source object</param>
        public DependsOnAttribute(string source, string property)
        {
            Property = property;
            Source = source;
        }

        /// <summary>
        /// The property that we depend on. 
        /// When this property changes we'll get a notify property changed as well
        /// </summary>
        public string Property { get; private set; }

        /// <summary>
        /// The source of the property change notification, only set this if the 
        /// property exists on an external object.
        /// </summary>
        public string Source { get; private set; }

    }
}
